# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import List
from fastapi import APIRouter, Depends, Request
from hypertext import R, PagingResult, response_json
from apps.api.schemas import square_schema as schema
from apps.api.service.square_service import SquareService

router = APIRouter(prefix="/square", tags=["广场接口"])


@router.get("/setting", summary="广场配置", response_model=R[List[schema.SquareSettingVo]])
@response_json
async def setting():
    return await SquareService.setting()


@router.get("/category", summary="广场分类", response_model=R[List[schema.SquareCategoryVo]])
@response_json
async def category(params: schema.SquareCategoryIn = Depends()):
    return await SquareService.category(params.type)


@router.get("/robot", summary="智能体广场", response_model=R[PagingResult[schema.SquareRobotVo]])
@response_json
async def robot(request: Request, params: schema.SquareSearchIn = Depends()):
    user_id: int = request.state.user_id
    return await SquareService.robot_list(user_id, params)


@router.get("/draws", summary="绘画广场")
@response_json
async def draws(request: Request, params: schema.SquareSearchIn = Depends()):
    user_id: int = request.state.user_id
    return await SquareService.draws_list(user_id, params)


@router.get("/video", summary="视频广场")
@response_json
async def video(request: Request, params: schema.SquareSearchIn = Depends()):
    user_id: int = request.state.user_id
    return await SquareService.video_list(user_id, params)


@router.get("/music", summary="音乐广场")
@response_json
async def music(request: Request, params: schema.SquareSearchIn = Depends()):
    user_id: int = request.state.user_id
    return await SquareService.music_list(user_id, params)
